﻿using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;

namespace Base.Infrastructure.EFCore.MySql
{
    public partial class oaContext : DbContext
    {
        public oaContext()
        {
        }

        public oaContext(DbContextOptions<oaContext> options)
            : base(options)
        {
        }

        public virtual DbSet<Arrange> Arranges { get; set; } = null!;
        public virtual DbSet<Class> Classes { get; set; } = null!;
        public virtual DbSet<ErrorLog> ErrorLogs { get; set; } = null!;
        public virtual DbSet<Login> Logins { get; set; } = null!;
        public virtual DbSet<Logsinfo> Logsinfos { get; set; } = null!;
        public virtual DbSet<Option> Options { get; set; } = null!;
        public virtual DbSet<Question> Questions { get; set; } = null!;
        public virtual DbSet<QuestionBank> QuestionBanks { get; set; } = null!;
        public virtual DbSet<QuestionBankDetail> QuestionBankDetails { get; set; } = null!;
        public virtual DbSet<TeaCher> TeaChers { get; set; } = null!;
        public virtual DbSet<TestPaper> TestPapers { get; set; } = null!;
        public virtual DbSet<TestPaperDetail> TestPaperDetails { get; set; } = null!;
        public virtual DbSet<UserExam> UserExams { get; set; } = null!;
        public virtual DbSet<Usert> Userts { get; set; } = null!;

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            if (!optionsBuilder.IsConfigured)
            {
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263.
                optionsBuilder.UseMySql("server=101.133.156.246;user id=root;password=167259qqQQ@;database=oa", Microsoft.EntityFrameworkCore.ServerVersion.Parse("8.0.29-mysql"));
            }
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.UseCollation("utf8mb4_0900_ai_ci")
                .HasCharSet("utf8mb4");

            modelBuilder.Entity<Arrange>(entity =>
            {
                entity.HasKey(e => e.Aid)
                    .HasName("PRIMARY");

                entity.ToTable("Arrange");

                entity.HasComment("安排表");

                entity.HasIndex(e => e.Aid, "AID")
                    .IsUnique();

                entity.Property(e => e.Aid)
                    .HasMaxLength(50)
                    .HasColumnName("AID")
                    .HasComment("安排ID");

                entity.Property(e => e.Aauthor)
                    .HasMaxLength(50)
                    .HasColumnName("AAuthor")
                    .HasComment("安排人");

                entity.Property(e => e.AbeginTime)
                    .HasMaxLength(50)
                    .HasColumnName("ABeginTime")
                    .HasComment("安排考试开始时间");

                entity.Property(e => e.Acids)
                    .HasMaxLength(50)
                    .HasColumnName("ACids")
                    .HasComment("被安排班级");

                entity.Property(e => e.AcreateTime)
                    .HasMaxLength(50)
                    .HasColumnName("ACreateTime")
                    .HasComment("添加时间");

                entity.Property(e => e.AendTime)
                    .HasMaxLength(50)
                    .HasColumnName("AEndTime")
                    .HasComment("安排考试结束时间");

                entity.Property(e => e.Aname)
                    .HasMaxLength(50)
                    .HasColumnName("AName")
                    .HasComment("安排说明");

                entity.Property(e => e.AtpId)
                    .HasMaxLength(50)
                    .HasColumnName("ATpID")
                    .HasComment("试卷ID");

                entity.Property(e => e.Auids)
                    .HasMaxLength(50)
                    .HasColumnName("AUids")
                    .HasComment("被安排考生");
            });

            modelBuilder.Entity<Class>(entity =>
            {
                entity.HasKey(e => e.Cid)
                    .HasName("PRIMARY");

                entity.HasComment("班级表");

                entity.HasIndex(e => e.Cid, "CID")
                    .IsUnique();

                entity.HasIndex(e => e.Cname, "CName")
                    .IsUnique();

                entity.Property(e => e.Cid)
                    .HasMaxLength(50)
                    .HasColumnName("CID")
                    .HasComment("班级Id");

                entity.Property(e => e.Ccount)
                    .HasColumnName("CCount")
                    .HasComment("班级人数");

                entity.Property(e => e.CcreateTime)
                    .HasMaxLength(50)
                    .HasColumnName("CCreateTime")
                    .HasComment("添加时间");

                entity.Property(e => e.CisActive)
                    .HasColumnName("CIsActive")
                    .HasComment("是否开班");

                entity.Property(e => e.CisFinish)
                    .HasColumnName("CIsFinish")
                    .HasComment("是否毕业");

                entity.Property(e => e.Cname)
                    .HasMaxLength(50)
                    .HasColumnName("CName")
                    .HasComment("班级名称");

                entity.Property(e => e.Ctype)
                    .HasMaxLength(50)
                    .HasColumnName("CType")
                    .HasComment("班级类型");
            });

            modelBuilder.Entity<ErrorLog>(entity =>
            {
                entity.HasKey(e => e.Eid)
                    .HasName("PRIMARY");

                entity.Property(e => e.Eid).HasMaxLength(50);

                entity.Property(e => e.Eapi).HasMaxLength(50);

                entity.Property(e => e.EcreateTime).HasMaxLength(50);

                entity.Property(e => e.Eip).HasMaxLength(50);

                entity.Property(e => e.Emessage).HasMaxLength(50);

                entity.Property(e => e.Eparams).HasMaxLength(50);

                entity.Property(e => e.Euid)
                    .HasMaxLength(50)
                    .HasColumnName("EUid");
            });

            modelBuilder.Entity<Login>(entity =>
            {
                entity.ToTable("login");

                entity.HasIndex(e => e.Account, "account")
                    .IsUnique();

                entity.Property(e => e.Id)
                    .HasMaxLength(50)
                    .HasColumnName("id")
                    .HasComment("id");

                entity.Property(e => e.Account)
                    .HasMaxLength(11)
                    .HasColumnName("account")
                    .HasComment("手机号");

                entity.Property(e => e.Createtime)
                    .HasMaxLength(50)
                    .HasColumnName("createtime")
                    .HasComment("创建时间");

                entity.Property(e => e.Name)
                    .HasMaxLength(10)
                    .HasColumnName("name")
                    .HasComment("名称");

                entity.Property(e => e.Password)
                    .HasMaxLength(50)
                    .HasColumnName("password")
                    .HasComment("密码");

                entity.Property(e => e.State)
                    .HasColumnName("state")
                    .HasComment("状态");
            });

            modelBuilder.Entity<Logsinfo>(entity =>
            {
                entity.ToTable("logsinfo");

                entity.Property(e => e.Id)
                    .HasMaxLength(50)
                    .HasColumnName("id");

                entity.Property(e => e.Lcode).HasMaxLength(255);

                entity.Property(e => e.Lid)
                    .HasMaxLength(50)
                    .HasColumnName("LID");

                entity.Property(e => e.Lip).HasMaxLength(255);

                entity.Property(e => e.LoginTime).HasMaxLength(50);
            });

            modelBuilder.Entity<Option>(entity =>
            {
                entity.HasKey(e => e.Oid)
                    .HasName("PRIMARY");

                entity.HasComment("选项表(答案表)");

                entity.Property(e => e.Oid)
                    .HasMaxLength(50)
                    .HasColumnName("OID")
                    .HasComment("选项ID");

                entity.Property(e => e.Ocontent)
                    .HasMaxLength(225)
                    .HasColumnName("OContent")
                    .HasComment("选项内容");

                entity.Property(e => e.OisRight)
                    .HasColumnName("OIsRight")
                    .HasComment("是否是正确答案");

                entity.Property(e => e.Oqid)
                    .HasMaxLength(50)
                    .HasColumnName("OQID")
                    .HasComment("题目ID");
            });

            modelBuilder.Entity<Question>(entity =>
            {
                entity.HasKey(e => e.Qid)
                    .HasName("PRIMARY");

                entity.ToTable("Question");

                entity.HasComment("试卷表");

                entity.Property(e => e.Qid)
                    .HasMaxLength(50)
                    .HasColumnName("QID")
                    .HasComment("题目id");

                entity.Property(e => e.Qcontent)
                    .HasMaxLength(50)
                    .HasColumnName("QContent")
                    .HasComment("题目");

                entity.Property(e => e.QcreateTime)
                    .HasMaxLength(50)
                    .HasColumnName("QCreateTime")
                    .HasComment("添加时间");

                entity.Property(e => e.Qexplain)
                    .HasMaxLength(255)
                    .HasColumnName("QExplain")
                    .HasComment("描述");

                entity.Property(e => e.QisBan)
                    .HasColumnName("QIsBan")
                    .HasComment("是否禁用");

                entity.Property(e => e.QisPublish)
                    .HasColumnName("QIsPublish")
                    .HasComment("是否发布");

                entity.Property(e => e.Qlv)
                    .HasColumnName("QLv")
                    .HasComment("难度等级1-10");

                entity.Property(e => e.Qsubject)
                    .HasMaxLength(50)
                    .HasColumnName("QSubject")
                    .HasComment("科目");

                entity.Property(e => e.Qtype)
                    .HasMaxLength(50)
                    .HasColumnName("QType")
                    .HasComment("题目类型");
            });

            modelBuilder.Entity<QuestionBank>(entity =>
            {
                entity.HasKey(e => e.Qbid)
                    .HasName("PRIMARY");

                entity.ToTable("QuestionBank");

                entity.HasComment("题库表");

                entity.HasIndex(e => e.Qbid, "QBID")
                    .IsUnique();

                entity.HasIndex(e => e.Qbname, "QBName")
                    .IsUnique();

                entity.Property(e => e.Qbid)
                    .HasMaxLength(50)
                    .HasColumnName("QBID")
                    .HasComment("题库ID");

                entity.Property(e => e.Qbcount)
                    .HasColumnName("QBCount")
                    .HasComment("题目数量");

                entity.Property(e => e.QbcreateTime)
                    .HasMaxLength(50)
                    .HasColumnName("QBCreateTime")
                    .HasComment("创建时间");

                entity.Property(e => e.Qbexplain)
                    .HasMaxLength(225)
                    .HasColumnName("QBExplain")
                    .HasComment("描述");

                entity.Property(e => e.QbisBan)
                    .HasColumnName("QBIsBan")
                    .HasComment("是否禁用");

                entity.Property(e => e.QbisPublish)
                    .HasColumnName("QBIsPublish")
                    .HasComment("是否发布");

                entity.Property(e => e.Qbname)
                    .HasMaxLength(50)
                    .HasColumnName("QBName")
                    .HasComment("题库名");

                entity.Property(e => e.Qbtype)
                    .HasMaxLength(50)
                    .HasColumnName("QBType")
                    .HasComment("题库类型");
            });

            modelBuilder.Entity<QuestionBankDetail>(entity =>
            {
                entity.HasKey(e => e.Qbdid)
                    .HasName("PRIMARY");

                entity.HasComment("题库详情");

                entity.HasIndex(e => e.Qbdid, "QBDID")
                    .IsUnique();

                entity.Property(e => e.Qbdid)
                    .HasMaxLength(50)
                    .HasColumnName("QBDID")
                    .HasComment("题库详情ID");

                entity.Property(e => e.QbdcreateTime)
                    .HasMaxLength(50)
                    .HasColumnName("QBDCreateTime")
                    .HasComment("创建时间");

                entity.Property(e => e.QbdisBan)
                    .HasColumnName("QBDIsBan")
                    .HasComment("是否禁用");

                entity.Property(e => e.Qbdqbid)
                    .HasMaxLength(50)
                    .HasColumnName("QBDQBID")
                    .HasComment("题库ID(QuestionBank )");

                entity.Property(e => e.Qbdqid)
                    .HasMaxLength(50)
                    .HasColumnName("QBDQID")
                    .HasComment("题目ID(Question )");
            });

            modelBuilder.Entity<TeaCher>(entity =>
            {
                entity.HasKey(e => e.Tcid)
                    .HasName("PRIMARY");

                entity.ToTable("TeaCher");

                entity.HasComment("职员表");

                entity.HasIndex(e => e.Tcid, "TCID")
                    .IsUnique();

                entity.Property(e => e.Tcid)
                    .HasMaxLength(50)
                    .HasColumnName("TCID")
                    .HasComment("职员id");

                entity.Property(e => e.Tcaccoun)
                    .HasMaxLength(50)
                    .HasColumnName("TCAccoun")
                    .HasComment("账号");

                entity.Property(e => e.Tccode)
                    .HasMaxLength(50)
                    .HasColumnName("TCCode")
                    .HasComment("Code");

                entity.Property(e => e.Tcdesignation)
                    .HasMaxLength(50)
                    .HasColumnName("TCDesignation")
                    .HasComment("职务");

                entity.Property(e => e.Tcname)
                    .HasMaxLength(50)
                    .HasColumnName("TCName")
                    .HasComment("职员姓名");

                entity.Property(e => e.TcopenId)
                    .HasMaxLength(50)
                    .HasColumnName("TCOpenID")
                    .HasComment("登录凭证");

                entity.Property(e => e.Verification)
                    .HasMaxLength(50)
                    .HasColumnName("verification")
                    .HasComment("验证码");
            });

            modelBuilder.Entity<TestPaper>(entity =>
            {
                entity.HasKey(e => e.Tpid)
                    .HasName("PRIMARY");

                entity.ToTable("TestPaper");

                entity.HasComment("试卷表");

                entity.Property(e => e.Tpid)
                    .HasMaxLength(50)
                    .HasColumnName("TPID")
                    .HasComment("试卷ID");

                entity.Property(e => e.Tpaction)
                    .HasColumnName("TPAction")
                    .HasComment("组卷方式 1:人工组卷 2:随机组卷 3:人工+随机组卷");

                entity.Property(e => e.Tpauthor)
                    .HasMaxLength(50)
                    .HasColumnName("TPAuthor")
                    .HasComment("添加人");

                entity.Property(e => e.Tpcids)
                    .HasMaxLength(50)
                    .HasColumnName("TPCIDs")
                    .HasComment("适用班级ID");

                entity.Property(e => e.TpcreateTime)
                    .HasMaxLength(50)
                    .HasColumnName("TPCreateTime")
                    .HasComment("添加时间");

                entity.Property(e => e.TpisBan)
                    .HasColumnName("TPIsBan")
                    .HasComment("是否禁用");

                entity.Property(e => e.TpisPublish)
                    .HasColumnName("TPIsPublish")
                    .HasComment("是否发布");

                entity.Property(e => e.Tplabels)
                    .HasMaxLength(50)
                    .HasColumnName("TPLabels")
                    .HasComment("试卷标签");

                entity.Property(e => e.Tplv)
                    .HasColumnName("TPLv")
                    .HasComment("试卷难度1-10");

                entity.Property(e => e.Tpname)
                    .HasMaxLength(99)
                    .HasColumnName("TPName")
                    .HasComment("试卷名");

                entity.Property(e => e.TppassScore)
                    .HasColumnName("TPPassScore")
                    .HasComment("及格分数");

                entity.Property(e => e.Tpqcount)
                    .HasColumnName("TPQCount")
                    .HasComment("题目数量");

                entity.Property(e => e.TptotalScore)
                    .HasColumnName("TPTotalScore")
                    .HasComment("总分");
            });

            modelBuilder.Entity<TestPaperDetail>(entity =>
            {
                entity.HasKey(e => e.Tpdid)
                    .HasName("PRIMARY");

                entity.HasComment("试卷详情表");

                entity.Property(e => e.Tpdid)
                    .HasMaxLength(50)
                    .HasColumnName("TPDID")
                    .HasComment("试卷详情ID");

                entity.Property(e => e.Tpdqid)
                    .HasMaxLength(50)
                    .HasColumnName("TPDQID")
                    .HasComment("题目ID");

                entity.Property(e => e.Tpdscore)
                    .HasColumnName("TPDScore")
                    .HasComment("题目分数");

                entity.Property(e => e.Tpdtpid)
                    .HasMaxLength(50)
                    .HasColumnName("TPDTPID")
                    .HasComment("试卷ID");
            });

            modelBuilder.Entity<UserExam>(entity =>
            {
                entity.HasKey(e => e.Ueid)
                    .HasName("PRIMARY");

                entity.ToTable("UserExam");

                entity.HasComment("考试表");

                entity.Property(e => e.Ueid)
                    .HasMaxLength(50)
                    .HasColumnName("UEID")
                    .HasComment("考试ID");

                entity.Property(e => e.Ueaid)
                    .HasMaxLength(50)
                    .HasColumnName("UEAID")
                    .HasComment("考试安排ID");

                entity.Property(e => e.UecheckUid)
                    .HasMaxLength(50)
                    .HasColumnName("UECheckUID")
                    .HasComment("阅卷人");

                entity.Property(e => e.Uecode)
                    .HasMaxLength(50)
                    .HasColumnName("UECode")
                    .HasComment("考试人员验证码，添加个人的openid(防止帮别人代考)数据库有该id则无法交卷");

                entity.Property(e => e.UecreateTime)
                    .HasMaxLength(50)
                    .HasColumnName("UECreateTime")
                    .HasComment("考试创建时间");

                entity.Property(e => e.UefinishTime)
                    .HasMaxLength(50)
                    .HasColumnName("UEFinishTime")
                    .HasComment("考生结束时间");

                entity.Property(e => e.UeisCheck)
                    .HasColumnName("UEIsCheck")
                    .HasComment("是否阅卷完成");

                entity.Property(e => e.Uescore)
                    .HasColumnName("UEScore")
                    .HasComment("考试得分");

                entity.Property(e => e.UestartTime)
                    .HasMaxLength(50)
                    .HasColumnName("UEStartTime")
                    .HasComment("考生开始时间");

                entity.Property(e => e.Uestate)
                    .HasColumnName("UEState")
                    .HasComment("状态(-1:待考试/ 0:正在考试/1:已交卷)");

                entity.Property(e => e.Ueuid)
                    .HasMaxLength(50)
                    .HasColumnName("UEUID")
                    .HasComment("考生ID(usert)");
            });

            modelBuilder.Entity<Usert>(entity =>
            {
                entity.HasKey(e => e.Uid)
                    .HasName("PRIMARY");

                entity.ToTable("usert");

                entity.Property(e => e.Uid)
                    .HasMaxLength(50)
                    .HasColumnName("UId")
                    .HasComment("id");

                entity.Property(e => e.Uaccount)
                    .HasMaxLength(11)
                    .HasColumnName("UAccount")
                    .HasComment("账号");

                entity.Property(e => e.Ucid)
                    .HasMaxLength(50)
                    .HasColumnName("UCID")
                    .HasComment("班级ID");

                entity.Property(e => e.Ucode)
                    .HasMaxLength(50)
                    .HasColumnName("UCode");

                entity.Property(e => e.UisBan)
                    .HasMaxLength(255)
                    .HasColumnName("UIsBan")
                    .HasComment("是否禁用");

                entity.Property(e => e.Uname)
                    .HasMaxLength(50)
                    .HasColumnName("UName")
                    .HasComment("姓名");

                entity.Property(e => e.Uopenid)
                    .HasMaxLength(50)
                    .HasColumnName("UOpenid");

                entity.Property(e => e.Verification)
                    .HasMaxLength(255)
                    .HasColumnName("verification")
                    .HasComment("验证码");
            });

            OnModelCreatingPartial(modelBuilder);
        }

        partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
    }
}
